<?php 
class tang extends CI_Controller {
	function index(){
		/*
		$this->load->library('pagination');
		$this->load->library('table');
		
		$config['base_url'] = 'http://localhost/ci/index.php/tang/index';
		$config['total_rows'] = $this->db->get('data')->num_rows();
		$config['per_page'] = 10;
		$config['num_links'] = 5;
		$config['full_tag_open'] = '<div id="pagination">';
		$config['full_tag_close'] = '</div>';

		$this->pagination->initialize($config);
		
		$data['records'] = $this->db->get('data', $config['per_page'], $this->uri->segment(3));
		*/
			$this->load->model('tang_model');
			$data = array();
			
			if($query = $this->tang_model->get_records())
			{
				$data['records'] = $query;
			}
			
			
			$this->load->view('tang_view',$data);
		}
		
		function insert()
		{
			$this->load->model('tang_model');
			$this->load->helper('date');
			
			
			$data = array(
				'id' => '',
				'pid' => '',
				'content' => $this->input->post('words') ,
				'create_date' => unix_to_human(gmt_to_local(time(), 'UP8', FALSE), TRUE, 'eu')
			);
			
			$this->tang_model->add_record($data);
			$this->index();
		}
}
?>